﻿Imports Microsoft.TeamFoundation.WorkItemTracking.Client

Module TFSModule

    <System.Runtime.CompilerServices.Extension()> _
    Public Function ComputeWidthInNodes(ByVal Value As Node, Optional ByRef CurrentWidth As Integer = 0) As Integer
        Dim newUnit As Integer = 0
        If Value.HasChildNodes Then
            If newUnit = 0 Then
                newUnit = newUnit + Value.ChildNodes.Count
            Else
                newUnit = newUnit + Value.ChildNodes.Count - 1
            End If
            For Each sNode As Node In Value.ChildNodes
                newUnit = ComputeWidthInNodes(sNode, newUnit)
            Next
        Else
            If CurrentWidth = 0 Then
                CurrentWidth = CurrentWidth + 1
            End If
        End If
        Return CurrentWidth + newUnit
    End Function


End Module
